package com.employee.model;

import com.common.json.JsonModel;
import com.entities.EventLibrary;
import com.entities.Faq;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.json.simple.JSONObject;

@Stateless
public class FaqFacade extends AbstractFacade<Faq> implements FaqFacadeLocal
{
    @PersistenceContext(unitName = "BluePumpkinEJBPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager()
    {
        return em;
    }

    public FaqFacade()
    {
        super(Faq.class);
    }

    @Override
    public List<String> getAllFAQ()
    {
        List<String> jsonlist = new ArrayList<String>();
        Query showAll = em.createNamedQuery("Faq.findAll");        
        List<Faq> results = showAll.getResultList();        
        for (Faq obj : results) {              
            JSONObject jsonObj = JsonModel.faqMessageSender(obj);
            String json = jsonObj.toString();
            jsonlist.add(json);
        }
        return jsonlist;
    }

}
